package com.kiln.juxingqs.adapter

import androidx.recyclerview.widget.DiffUtil
import client.global.commlib.base.BasePagingAdapter
import client.global.commlib.base.PagingViewHoder
import com.kiln.juxingqs.R
import com.kiln.juxingqs.api.bean.Zcjl
import com.kiln.juxingqs.databinding.LayoutXyzritemBinding

class PagingXyzrAdapter :
    BasePagingAdapter<Zcjl.Record>(object : DiffUtil.ItemCallback<Zcjl.Record>() {
        override fun areItemsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return false
        }

        override fun areContentsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return oldItem == newItem
        }
    }) {

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutXyzritemBinding
        val bean = t as Zcjl.Record
        binding.bean = bean
        when (bean.r_state) {
            1 -> {
                binding.num = "+${bean.num}"
            }
            2 -> {
                binding.num = "-${bean.num}"
            }
        }

        val time = bean.create_time.substring(5, bean.create_time.length - 3)
        binding.time = time
    }

    override fun getItemLayout(): Int {
        return R.layout.layout_xyzritem
    }
}